package 链接snappydate数据库相关操作.snappydateDDL相关操作
import java.sql.{Connection, DriverManager}

import org.apache.spark.sql.SnappySession
import org.apache.spark.{SparkConf, SparkContext}

import scala.collection.mutable

object SnappySessionHelper {
  var snappySession : SnappySession = _




  def disconnect(): Unit = {
    snappySession.stop()
  }



  def connect(strURL:String): Unit = {
    try {
      val conf: SparkConf = new SparkConf()
        .setAppName("APP")
        .set("spark.ui.port", "4041")
        .set("spark.snappydata.connection", strURL)
        .setMaster("local[*]")
        .set("spark.sql.warehouse.dir", "/tmp/warehouse")
      snappySession = new SnappySession(new SparkContext(conf))
    } catch {
      case ex: Exception =>
        ex.printStackTrace()
    }
  }
  //  def connect(appName:String,port:String,url:String,master:String): Unit ={
  //    try {
  //      val conf: SparkConf = new SparkConf()
  //        .setAppName(appName)
  //        .set("spark.ui.port", port)
  //        .set("spark.snappydata.connection",url)
  //        .setMaster(master)
  //        .set("spark.sql.warehouse.dir","/tmp/loaddata/warehouse")
  //      snappySession = new SnappySession(new SparkContext(conf))
  //    } catch {
  //      case ex: Exception =>
  //        ex.printStackTrace()
  //    }
  //  }
}

